package com.alibaba.otter.node.etl.load.loader.mq.rabbit.resolver;

import com.alibaba.otter.node.etl.load.loader.mq.rabbit.model.ConnectionSetting;
import com.alibaba.otter.node.etl.load.loader.mq.rabbit.model.RabbitMqNamespace;
import com.alibaba.otter.node.etl.load.loader.mq.rabbit.namespace.AbstractSettingResolver;
import lombok.NoArgsConstructor;

import java.util.Map;

@NoArgsConstructor
@SuppressWarnings({"rawtypes", "unchecked"})
public class RabbitMqNamespaceResolver extends AbstractSettingResolver<RabbitMqNamespace> {

    private String type = "mq";

    public RabbitMqNamespaceResolver(String name) {
        this.name = name;
    }

    @Override
    public String getType() {
        return type;
    }

    @Override
    public RabbitMqNamespace resolve(Map properties) {
        RabbitMqNamespace namespace = new RabbitMqNamespace();
        namespace.setName(getName());
        ConnectionSetting setting = resolveSetting(properties, ConnectionSetting.class);
        namespace.setSetting(setting);
        return namespace;
    }
}
